package cn.com.zs.android.app;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Window;
import android.view.WindowManager;
import cn.com.zs.android.model.GameParams;
import cn.com.zs.android.model.PhoneParams;
import cn.com.zs.android.service.BackGroundMusicService;
import cn.com.zs.android.view.DrawBackground;

/**
 * 开始游戏, 设置参数、渲染游戏界面
 * @author 	曾帅
 */
public class StartGameActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        this.setPhoneParams();
        GameParams.resetGameTime();
        setContentView(new DrawBackground(this));
        Intent intent = new Intent(StartGameActivity.this, BackGroundMusicService.class);
        startService(intent);
    }
    
    private void setPhoneParams() {
    	DisplayMetrics dm = new DisplayMetrics();  
        getWindowManager().getDefaultDisplay().getMetrics(dm);  
        PhoneParams.width = dm.widthPixels;  
        PhoneParams.height = dm.heightPixels;
        requestWindowFeature(Window.FEATURE_NO_TITLE); 
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		
		Intent intent = new Intent(StartGameActivity.this, BackGroundMusicService.class);
		stopService(intent);
		finish();
	}
    
}
